home *** CD-ROM | disk | FTP | other *** search
/ APDL Eductation Resources / APDL Eductation Resources.iso / programs / electronic / rlab / TestMatrix / invol_r < prev    next >
Encoding:
Text File  |  1994-12-20  |  994 b   |  41 lines

  1. //-------------------------------------------------------------------//
  2.  
  3. // Synopsis:    An involutory matrix.
  4.  
  5. // Syntax:      A = invol ( N )
  6.  
  7. // Description:
  8.  
  9. //      A is an N-by-N involutory (A*A = EYE(N)) and ill-conditioned
  10. //      matrix. It is a diagonally scaled version of HILB(N). 
  11.  
  12. //      NB: B = (EYE(M,N)-A)/2 and B = (EYE(N)+A)/2 are idempotent (B*B = B). 
  13.  
  14. //      Reference:
  15. //      A.S. Householder and J.A. Carpenter, The singular values
  16. //      of involutory and of idempotent matrices, Numer. Math. 5 (1963),
  17. //      pp. 234-237.
  18.  
  19. //    This file is a translation of invol.m from version 2.0 of
  20. //    "The Test Matrix Toolbox for Matlab", described in Numerical
  21. //    Analysis Report No. 237, December 1993, by N. J. Higham.
  22.  
  23. //-------------------------------------------------------------------//
  24.  
  25. invol = function ( n )
  26. {
  27.   local (n)
  28.  
  29.   A = hilb(n);
  30.  
  31.   d = -n;
  32.   A[;1] = d*A[;1];
  33.  
  34.   for (i in 1:n-1)
  35.   {
  36.     d = -(n+i)*(n-i)*d/(i*i);
  37.     A[i+1;] = d*A[i+1;];
  38.   }
  39.   return A;
  40. };
  41.